
             
/**
 * 
 *
 * @File name:  AddTFaChangeFlowAction.java   添加【资产变更流水:T_FA_CHANGE_FLOW】
 * @Create on:  2011-11-01 16:57:390
 * @Author   :  许福辉
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        
package com.boho.estates.usual.action;

            
import java.sql.Connection;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.POUtils;
import cn.boho.framework.service.MessageService;

import com.boho.common.SystemUtils;
import com.boho.estates.po.TFaChangeFlowPO;
import com.boho.estates.po.TFixedAssetsDetailPO;

public class AddTFaChangeFlowAction extends ActionImp {
	private TFaChangeFlowPO tFaChangeFlowPO = new TFaChangeFlowPO();
	private Connection con=null;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			atx.setErrorContext("BOHO_COMMON_1001", MessageService.getMessage("BOHO_COMMON_1001"),"【资产变更流水】", ex);
		}
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		System.out.println("==="+tFaChangeFlowPO.getChangeType());
		POUtils.insert(con, tFaChangeFlowPO,false);
		
		TFixedAssetsDetailPO tFixedAssetsDetailPO = new TFixedAssetsDetailPO();
		TFixedAssetsDetailPO vFixedAssetsDetailPO = new TFixedAssetsDetailPO();
		tFixedAssetsDetailPO.setId(atx.getIntegerValue("ID",-1));
		
		vFixedAssetsDetailPO.setFaStatus(tFaChangeFlowPO.getChangeType());
		POUtils.update(con, tFixedAssetsDetailPO, vFixedAssetsDetailPO,false);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		String createBy = SystemUtils.getSessionUser(atx);
		tFaChangeFlowPO.setBarcode(atx.getStringValue("BARCODE"));
		tFaChangeFlowPO.setChangeType(atx.getStringValue("CHANGE_TYPE"));
		java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");    
		tFaChangeFlowPO.setChangeDate(new java.util.Date(format.parse(atx.getStringValue("CHANGE_DATE")).getTime()));
		tFaChangeFlowPO.setChageReason(atx.getStringValue("CHAGE_REASON"));
		tFaChangeFlowPO.setBeforPrice(atx.getDoubleValue("BEFOR_PRICE"));
		tFaChangeFlowPO.setAfterPrice(atx.getDoubleValue("AFTER_PRICE"));
		tFaChangeFlowPO.setPerson(atx.getStringValue("PERSON"));
		tFaChangeFlowPO.setRemark(atx.getStringValue("REMARK"));
		tFaChangeFlowPO.setIsValid(1);
		tFaChangeFlowPO.setCreateBy(createBy);
		tFaChangeFlowPO.setCreateDate(new java.util.Date());
		return 1;
	}
}
